﻿namespace Vdc.Interface
{
    using System;
    using System.ComponentModel;
    using System.Text;

    public class VdcTextBoxClientSideEvents : VdcPersistentObject
    {
        internal virtual string SerializeToJSON()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("{");
            bool flag = false;
            if (!string.IsNullOrEmpty(this.OnTextChanged))
            {
                builder.Append("'OnTextChanged': " + this.OnTextChanged);
                flag = true;
            }
            if (!string.IsNullOrEmpty(this.OnKeyDown))
            {
                if (flag)
                {
                    builder.Append(",");
                }
                builder.Append("'OnKeyDown': " + this.OnKeyDown);
                flag = true;
            }
            if (!string.IsNullOrEmpty(this.OnKeyPress))
            {
                if (flag)
                {
                    builder.Append(",");
                }
                builder.Append("'OnKeyPress': " + this.OnKeyPress);
                flag = true;
            }
            if (!string.IsNullOrEmpty(this.OnKeyUp))
            {
                if (flag)
                {
                    builder.Append(",");
                }
                builder.Append("'OnKeyUp': " + this.OnKeyUp);
                flag = true;
            }
            builder.Append("}");
            return builder.ToString();
        }

        [DefaultValue(""), Category("Client-Side Events"), Description("Client-side function to be executed when a key is pressed."), Bindable(true)]
        public string OnKeyDown
        {
            get
            {
                object obj2 = this.ViewState["OnKeyDown"];
                if (obj2 != null)
                {
                    return obj2.ToString();
                }
                return "";
            }
            set
            {
                this.ViewState["OnKeyDown"] = value;
            }
        }

        [Bindable(true), Description("Client-side function to be executed when a key is pressed."), Category("Client-Side Events"), DefaultValue("")]
        public string OnKeyPress
        {
            get
            {
                object obj2 = this.ViewState["OnKeyPress"];
                if (obj2 != null)
                {
                    return obj2.ToString();
                }
                return "";
            }
            set
            {
                this.ViewState["OnKeyPress"] = value;
            }
        }

        [DefaultValue(""), Description("Client-side function to be executed after a key is pressed."), Bindable(true), Category("Client-Side Events")]
        public string OnKeyUp
        {
            get
            {
                object obj2 = this.ViewState["OnKeyUp"];
                if (obj2 != null)
                {
                    return obj2.ToString();
                }
                return "";
            }
            set
            {
                this.ViewState["OnKeyUp"] = value;
            }
        }

        [DefaultValue(""), Bindable(true), Description("Client-side function to be executed after the text is changed."), Category("Client-Side Events")]
        public string OnTextChanged
        {
            get
            {
                object obj2 = this.ViewState["OnTextChanged"];
                if (obj2 != null)
                {
                    return obj2.ToString();
                }
                return "";
            }
            set
            {
                this.ViewState["OnTextChanged"] = value;
            }
        }
    }
}

